package com.openbravo.pos.mant;

import com.openbravo.basic.BasicException;
import com.openbravo.data.gui.ComboBoxValModel;
import com.openbravo.data.loader.SentenceList;
import com.openbravo.data.user.DirtyManager;
import com.openbravo.data.user.EditorRecord;
import com.openbravo.format.Formats;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.forms.DataLogicSales;
import java.awt.Component;
import java.util.UUID;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.text.Document;

public class PlacesEditor extends JPanel
  implements EditorRecord
{
  private SentenceList m_sentfloor;
  private ComboBoxValModel m_FloorModel;
  private String m_sID;
  private JLabel jLabel1;
  private JLabel jLabel2;
  private JLabel jLabel3;
  private JComboBox m_jFloor;
  private JTextField m_jName;
  private JTextField m_jX;
  private JTextField m_jY;

  public PlacesEditor(DataLogicSales paramDataLogicSales, DirtyManager paramDirtyManager)
  {
    initComponents();
    this.m_sentfloor = paramDataLogicSales.getFloorsList();
    this.m_FloorModel = new ComboBoxValModel();
    this.m_jName.getDocument().addDocumentListener(paramDirtyManager);
    this.m_jFloor.addActionListener(paramDirtyManager);
    this.m_jX.getDocument().addDocumentListener(paramDirtyManager);
    this.m_jY.getDocument().addDocumentListener(paramDirtyManager);
    writeValueEOF();
  }

  public void activate()
    throws BasicException
  {
    this.m_FloorModel = new ComboBoxValModel(this.m_sentfloor.list());
    this.m_jFloor.setModel(this.m_FloorModel);
  }

  public void refresh()
  {
  }

  public void writeValueEOF()
  {
    this.m_sID = null;
    this.m_jName.setText(null);
    this.m_FloorModel.setSelectedKey(null);
    this.m_jX.setText(null);
    this.m_jY.setText(null);
    this.m_jName.setEnabled(false);
    this.m_jFloor.setEnabled(false);
    this.m_jX.setEnabled(false);
    this.m_jY.setEnabled(false);
  }

  public void writeValueInsert()
  {
    this.m_sID = UUID.randomUUID().toString();
    this.m_jName.setText(null);
    this.m_FloorModel.setSelectedKey(null);
    this.m_jX.setText(null);
    this.m_jY.setText(null);
    this.m_jName.setEnabled(true);
    this.m_jFloor.setEnabled(true);
    this.m_jX.setEnabled(true);
    this.m_jY.setEnabled(true);
  }

  public void writeValueDelete(Object paramObject)
  {
    Object[] arrayOfObject = (Object[])(Object[])paramObject;
    this.m_sID = Formats.STRING.formatValue(arrayOfObject[0]);
    this.m_jName.setText(Formats.STRING.formatValue(arrayOfObject[1]));
    this.m_jX.setText(Formats.INT.formatValue(arrayOfObject[2]));
    this.m_jY.setText(Formats.INT.formatValue(arrayOfObject[3]));
    this.m_FloorModel.setSelectedKey(arrayOfObject[4]);
    this.m_jName.setEnabled(false);
    this.m_jFloor.setEnabled(false);
    this.m_jX.setEnabled(false);
    this.m_jY.setEnabled(false);
  }

  public void writeValueEdit(Object paramObject)
  {
    Object[] arrayOfObject = (Object[])(Object[])paramObject;
    this.m_sID = Formats.STRING.formatValue(arrayOfObject[0]);
    this.m_jName.setText(Formats.STRING.formatValue(arrayOfObject[1]));
    this.m_jX.setText(Formats.INT.formatValue(arrayOfObject[2]));
    this.m_jY.setText(Formats.INT.formatValue(arrayOfObject[3]));
    this.m_FloorModel.setSelectedKey(arrayOfObject[4]);
    this.m_jName.setEnabled(true);
    this.m_jFloor.setEnabled(true);
    this.m_jX.setEnabled(true);
    this.m_jY.setEnabled(true);
  }

  public Object createValue()
    throws BasicException
  {
    Object[] arrayOfObject = new Object[5];
    arrayOfObject[0] = this.m_sID;
    arrayOfObject[1] = this.m_jName.getText();
    arrayOfObject[2] = Formats.INT.parseValue(this.m_jX.getText());
    arrayOfObject[3] = Formats.INT.parseValue(this.m_jY.getText());
    arrayOfObject[4] = this.m_FloorModel.getSelectedKey();
    return arrayOfObject;
  }

  public Component getComponent()
  {
    return this;
  }

  private void initComponents()
  {
    this.jLabel2 = new JLabel();
    this.m_jName = new JTextField();
    this.jLabel3 = new JLabel();
    this.m_jX = new JTextField();
    this.m_jY = new JTextField();
    this.jLabel1 = new JLabel();
    this.m_jFloor = new JComboBox();
    setLayout(null);
    this.jLabel2.setText(AppLocal.getIntString("Label.Name"));
    add(this.jLabel2);
    this.jLabel2.setBounds(20, 20, 90, 15);
    add(this.m_jName);
    this.m_jName.setBounds(110, 20, 180, 19);
    this.jLabel3.setText(AppLocal.getIntString("label.placeposition"));
    add(this.jLabel3);
    this.jLabel3.setBounds(20, 80, 90, 15);
    add(this.m_jX);
    this.m_jX.setBounds(110, 80, 50, 19);
    add(this.m_jY);
    this.m_jY.setBounds(170, 80, 50, 19);
    this.jLabel1.setText(AppLocal.getIntString("label.placefloor"));
    add(this.jLabel1);
    this.jLabel1.setBounds(20, 50, 90, 15);
    add(this.m_jFloor);
    this.m_jFloor.setBounds(110, 50, 170, 20);
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.mant.PlacesEditor
 * JD-Core Version:    0.6.0
 */